package com.cn.springcloudwechat.serviceImpl.articleAndMenu;

import com.cn.springcloudwechat.common.mybatis.Page;
import com.cn.springcloudwechat.mapper.mapper.articleAndMenu.YmVideoKnowledgeMapper;
import com.cn.springcloudwechat.model.articleAndMenu.YmVideoKnowledge;
import com.cn.springcloudwechat.service.articleAndMenu.YmArticleService;
import com.cn.springcloudwechat.service.articleAndMenu.YmVideoKnowledgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 视频知识
 *
 * @author: Administrator
 * @create: 2018/8/1 16:00
 */
@Service
public class YmVideoKnowledgeServiceImpl  implements YmVideoKnowledgeService {

    @Autowired
    private YmVideoKnowledgeMapper ymVideoKnowledgeMapper;
  /*  @Autowired
    YmArticleService ymArticleService;*/
    private static final String RELEVANCE_TPYE_ID_VIDEO="9";

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long insertSelective(YmVideoKnowledge record) {
       long videoId= ymVideoKnowledgeMapper.insertSelective(record);
      //  ymArticleService.insterYmAttachmentRelevance(record.getVideoId(),RELEVANCE_TPYE_ID_VIDEO,attachmentId);
        return record.getVideoId();
    }

    @Override
    @Cacheable
    public YmVideoKnowledge selectByPrimaryKey(long videoId) {
        return  ymVideoKnowledgeMapper.selectByPrimaryKey(videoId);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateByPrimaryKeySelective(YmVideoKnowledge record) {
        ymVideoKnowledgeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<YmVideoKnowledge> getAllYmVideoKnowledge() {
        return ymVideoKnowledgeMapper.getAllYmVideoKnowledge();
    }

    @Override
    public Page<Object> getAllYmVideoKnowledgeByParameter(YmVideoKnowledge record,Page<Object> page) {
      List<Object> ymVideoKnowledges= ymVideoKnowledgeMapper.getAllYmVideoKnowledgeByParameter(record,page);
        page.setResults(ymVideoKnowledges);
        return page;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateYmVideoKnowledgeState(List<Long> videoId, short state) {
        ymVideoKnowledgeMapper.updateYmVideoKnowledgeState(videoId,state);
    }


}
